package supplier

import (
	"context"
	"git.mycaigou.com/gfyx/common/http_client"
	"git.mycaigou.com/gfyx/common/simplecopier"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/infrastructure/common/constants"
	bigdataDto "git.mycaigou.com/gfyx/micro-gfyx-mp-api/infrastructure/dto/bigdata"
	"git.mycaigou.com/gfyx/micro-gfyx-mp-api/service/business_opportunity/supplier"
	"git.myscrm.cn/golang/stark/v4"
)

type SupplierRepository struct {
}

// NewSupplierRepository
// 工程单位
func NewSupplierRepository() supplier.SupplierRepositoryIface {
	return &SupplierRepository{}
}

func (r *SupplierRepository) GetSupplierList(ctx context.Context, request *bigdataDto.GetSupplierListRequest) (*http_client.BigDataResponse, error) {
	resultData := &http_client.BigDataResponse{}
	paramsMap, err := simplecopier.StructToMapByJsonTag(request)
	if err != nil {
		stark.Logger.Errorf(ctx, "结构体转换map失败，err:%+v", err)
		return nil, err
	}
	header := make(map[string]string, 0)
	_, _, errs := http_client.NewBigdataApiHttpClient().Post(ctx, constants.BigDataPathSupplierList, paramsMap, header).EndStruct(&resultData)
	if len(errs) > 0 {
		return nil, errs[0]
	}
	return resultData, nil
}
